package printer.impl;

import java.util.Set;

import pojo.Customer;
import printer.DataPrinter;

public class DataPrinterImpl implements DataPrinter {

	public StringBuilder print(Set<Customer> customer, String format) {
		StringBuilder result=new StringBuilder();
		if("line".equals(format)){
			for(Customer c:customer){
				result.append(" id:").append(c.getId()).append(", name:").append(c.getName()).append(", email:").append(c.getEmail())
				.append(", sex:").append(c.getSex()).append(", birthday:").append(c.getBirthday()).append("\n");
				
			}
			return result;
		}
		else if("xml".equals(format)){
			result.append("<Customers>\n");
			for(Customer c:customer){
				result.append("\t<Customer id=\"").append(c.getId()).append("\">\n");
				result.append("\t\t<name>").append(c.getName()).append("</name>\n");
				result.append("\t\t<email>").append(c.getEmail()).append("</email>\n");
				result.append("\t\t<sex>").append(c.getSex()).append("</sex>\n");
				result.append("\t\t<birthday>").append(c.getBirthday()).append("</birthday>\n");
				result.append("\t</Customer>\n");
			}
			result.append("</Customers>\n");
			return result;
		}
		return null;
	}
	
	
}
